<?php
class cyitem_joinControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
	}
	
	public function onDefault(){
		$cyid=get_post('cyid','i');
		$cyitem=M("cyitem")->selectRow("id=".$cyid);
 		if(empty($cyitem)) $this->goAll("数据出错",1,0,"/index.php");
		$limit=20;
		$start=get_post("per_page","i");
		$option=array(
			"limit"=>$limit,
			"start"=>$start,
			"order"=>" id DESC",
			"where"=>" cyid=".$cyid." ",
		);
		$rscount=true;
		$data=M("cyitem_join")->select($option,$rscount);
		if($data){
			foreach($data as $v){
				$uids[]=$v['userid'];
			}
			$us=M("user")->getUserByIds($uids);
			foreach($data as $k=>$v){
				$u=$us[$v['userid']];
				$v['user_head']=$u['user_head'];
				$data[$k]=$v;
			}
		}
		$this->smarty->assign(array(
			"cyitem"=>$cyitem,
			"data"=>$data
		));
		$this->smarty->display("cyitem_join/index.html");
	}
	
	public function onShow(){
		$cyid=get_post('cyid','i');
		$cyitem=M("cyitem")->selectRow("id=".$cyid);
 		if(empty($cyitem)) $this->goAll("数据出错",1,0,"/index.php");
		$id=get('id','i');
		$data=M("cyitem_join")->selectRow("id=".$id);
		$this->smarty->assign(array(
			"cyitem"=>$cyitem,
			"data"=>$data
		));
		$this->smarty->display("cyitem_join/show.html");
	}
	
}

?>